package com.kmproject.haifu.mvp.ui.adapter;

import android.graphics.Typeface;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.utils.ArmsUtils;
import com.kmproject.haifu.R;
import com.kmproject.haifu.mvp.model.entity.beans.HousePayWayBean;

import java.util.List;

public class PopuWindowSelectAddress1Adapter extends BaseQuickAdapter<HousePayWayBean,BaseViewHolder> {
    private int selectIndex=-1;
    private BtncliickCallBack mbtncliickCallBack;
    private boolean isShowLine=false;

    public PopuWindowSelectAddress1Adapter(int defaultSelectIndex,@Nullable List<HousePayWayBean> data, BtncliickCallBack btncliickCallBack) {
        super(R.layout.popuwindows_seelct_adress_item1, data);
        mbtncliickCallBack=btncliickCallBack;
        selectIndex=defaultSelectIndex;
    }

    @Override
    protected void convert(BaseViewHolder helper, HousePayWayBean item) {
     helper.<TextView>getView(R.id.popuwindows_seelct_adress_item1_txt).setText(item.getName());
        helper.<TextView>getView(R.id.popuwindows_seelct_adress_item1_txt).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                selectIndex=helper.getPosition();
                if (mbtncliickCallBack!=null)
                {
                    mbtncliickCallBack.callBack(selectIndex,item);
                }
              notifyDataSetChanged();
            }
        });
      if (selectIndex==helper.getPosition())
      {
          helper.<TextView>getView(R.id.popuwindows_seelct_adress_item1_txt).setTextColor(ArmsUtils.getColor(mContext,R.color.color_191919));
          helper.<TextView>getView(R.id.popuwindows_seelct_adress_item1_txt) .setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));

      }else {
          helper.<TextView>getView(R.id.popuwindows_seelct_adress_item1_txt).setTextColor(ArmsUtils.getColor(mContext,R.color.color_747474));
          helper.<TextView>getView(R.id.popuwindows_seelct_adress_item1_txt) .setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
      }

        if (isShowLine)
        {
            helper.<View>getView(R.id.popuwindows_seelct_adress_item1_line).setVisibility(View.VISIBLE);
        }else {
            helper.<View>getView(R.id.popuwindows_seelct_adress_item1_line).setVisibility(View.GONE);
        }
    }

    public boolean isShowLine() {
        return isShowLine;
    }

    public void setShowLine(boolean showLine) {
        isShowLine = showLine;
    }

    public int getSelectIndex() {
        return selectIndex;
    }

    public void setSelectIndex(int selectIndex) {
        this.selectIndex = selectIndex;
    }

    public interface BtncliickCallBack{
        void callBack(int index, Object content);
    }
}
